<template>
	<div class="pages">
		<el-form :inline="true" size="small" :model="dataForm" label-width="80px">
			<el-form-item label="企业名称:">
				<el-input v-model="dataForm.keyword" placeholder="请输入" clearable></el-input>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="getDataList">搜索</el-button>
			</el-form-item>
		</el-form>
		<el-table :data="dataList" v-loading="dataListLoading" border style="width: 100%" header-align="center"
			:summary-method="getSummaries" show-summary>
			<el-table-column type="index" align="center" label="序号" width="60">
			</el-table-column>
			<el-table-column prop="name" align="center" label="企业名称">
			</el-table-column>
			<el-table-column prop="total_hetong_num" align="center" label="合同金额（元）">
			</el-table-column>
			<el-table-column prop="total_coupons_num" align="center" label="创制券使用(元)">
			</el-table-column>
			<el-table-column prop="total_xuqiu" align="center" label="需求数量">
			</el-table-column>
			<el-table-column prop="level_1_orders" align="center" label="设计研发需求">
			</el-table-column>
			<el-table-column prop="level_2_orders" align="center" label="物资采购需求">
			</el-table-column>
			<el-table-column prop="level_3_orders" align="center" label="生产加工需求">
			</el-table-column>
			<el-table-column prop="total_yiqian" align="center" label="合同归档">
			</el-table-column>
			<el-table-column prop="total_order" align="center" label="订单总数">
			</el-table-column>
			<el-table-column prop="total_jinxing" align="center" label="订单进行中">
			</el-table-column>
			<el-table-column prop="total_wancheng" align="center" label="订单已完成">
			</el-table-column>
			<el-table-column prop="total_zuofei" align="center" label="订单已作废">
			</el-table-column>
		</el-table>
		<el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
			layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
			@current-change="pageCurrentChangeHandle">
		</el-pagination>
	</div>
</template>

<script>
	import mixinViewModule from '@/mixins/view-module'
	export default {
		mixins: [mixinViewModule],
		data() {
			return {
				mixinViewModuleOptions: {
					getDataListURL: '/api/tongji/getlist',
					getDataListIsPage: true,
					deleteIsBatch: true,
					createdIsNeed: true,
				},
				dataForm: {
					keyword: '',
				},
				total2: {
					total_hetong_num: 0,
					order_num: 0,
					total_coupons_num: 0,
					total_xuqiu: 0,
					level_1_orders: 0,
					level_2_orders: 0,
					level_3_orders: 0,
					total_yiqian: 0,
					total_order: 0,
					total_jinxing: 0,
					total_wancheng: 0,
					total_zuofei: 0,
				},
			}
		},
		methods: {
			getSummaries(param) {
				const {
					columns,
					data
				} = param;
				const sums = [];
				columns.forEach((column, index) => {
					if (index === 0) {
						sums[index] = '总计';
					} else if (index === 1) {
						sums[index] = ''
					} else if (index === 2) {
						sums[index] = this.total2.total_hetong_num
					} else if (index === 3) {
						sums[index] = this.total2.total_coupons_num
					} else if (index === 4) {
						sums[index] = this.total2.total_xuqiu
					} else if (index === 5) {
						sums[index] = this.total2.level_1_orders
					} else if (index === 6) {
						sums[index] = this.total2.level_2_orders
					} else if (index === 7) {
						sums[index] = this.total2.level_3_orders
					} else if (index === 8) {
						sums[index] = this.total2.total_yiqian
					} else if (index === 9) {
						sums[index] = this.total2.total_order
					} else if (index === 10) {
						sums[index] = this.total2.total_jinxing
					} else if (index === 11) {
						sums[index] = this.total2.total_wancheng
					}else if (index === 12) {
						sums[index] = this.total2.total_zuofei
					}
				});
				return sums;
			},
			getTotal() {
				this.$http.post('/api/tongji/zongji', {}).then(res => {
					this.total2.total_hetong_num = Number(res.result.total_hetong_num)
					this.total2.order_num = Number(res.result.order_num)
					this.total2.total_coupons_num = Number(res.result.total_coupons_num)
					this.total2.total_xuqiu = Number(res.result.total_xuqiu)
					this.total2.level_1_orders = Number(res.result.level_1_orders)
					this.total2.level_2_orders = Number(res.result.level_2_orders)
					this.total2.level_3_orders = Number(res.result.level_3_orders)
					this.total2.total_yiqian = Number(res.result.total_yiqian)
					this.total2.total_order = Number(res.result.total_order)
					this.total2.total_jinxing = Number(res.result.total_jinxing)
					this.total2.total_wancheng = Number(res.result.total_wancheng)
					this.total2.total_zuofei = Number(res.result.total_zuofei)
				})
			},
		},
		created() {
			this.getTotal()
		}
	}
</script>

<style>
</style>